package com.bawei.lib_net.interceptor

import android.os.Build
import com.bawei.lib_storage.mmkv.AppMMKV
import com.bawei.lib_storage.mmkv.AuthMMKV
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response

/**
 * @author yaotianxue
 * @description 请求头拦截器
 * @date 2025/5/23
 */
class HttpHeadInterceptor:Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val original = chain.request() //获取原始请求
        val meid: String = AppMMKV.meid
        val requestBuilder = original.newBuilder()
            .addHeader("Content-Language", "")//BuildConfig.I18N_LANG
            .addHeader("platform", "ANDROID")
            .addHeader("source", "CLUB_APP")
            .addHeader("Authorization", AuthMMKV.token)
            .addHeader("meid", meid ?: "")//meid ?: ""
            .addHeader("version", "1.0.0") //BuildConfig.VERSION_NAME
            .addHeader("phoneModel", Build.BRAND + "_" + Build.MODEL)
        val request: Request = requestBuilder.build() //构建新的请求
        return chain.proceed(request)
    }
}